package com.ipad.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.ipad.R;

/**
 * Created by Administrator on 2018/12/3.
 */

public class LoadingDialog extends Dialog {
    LayoutInflater inflater;
    String inf="";
    TextView msg;
    public LoadingDialog(@NonNull Context context) {
        super(context);
        init(context);
    }

    public LoadingDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
        init(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View inflate = inflater.inflate(R.layout.loading_view, null,false);
        msg = inflate.findViewById(R.id.loading_msg);
        msg.setText(inf);
        setContentView(inflate);

        getWindow().setWindowAnimations(R.style.windowAnimotion);
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        attributes.width = getContext().getResources().getDisplayMetrics().widthPixels;
        getWindow().setAttributes(attributes);

    }

    public void init(Context context) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        inflater = LayoutInflater.from(context);
    }

    public void showDialog(String tst) {
        super.show();
    }

    public void setInf(String inf) {
        this.inf = inf;
    }
}
